home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 53 / PC Actual CD 53.iso / Share / Progra / python / BeOpen-Python-2.0.exe / TYPES.PY < prev    next >
Encoding:
Python Source  |  2000-09-28  |  1.4 KB  |  69 lines

  1. """Define names for all type symbols known in the standard interpreter.
  2.  
  3. Types that are part of optional modules (e.g. array) are not listed.
  4. """
  5.  
  6. import sys
  7.  
  8. NoneType = type(None)
  9. TypeType = type(NoneType)
  10.  
  11. IntType = type(0)
  12. LongType = type(0L)
  13. FloatType = type(0.0)
  14. try:
  15.     ComplexType = type(complex(0,1))
  16. except NameError:
  17.     pass
  18.  
  19. StringType = type('')
  20. UnicodeType = type(u'')
  21. BufferType = type(buffer(''))
  22.  
  23. TupleType = type(())
  24. ListType = type([])
  25. DictType = DictionaryType = type({})
  26.  
  27. def _f(): pass
  28. FunctionType = type(_f)
  29. LambdaType = type(lambda: None)         # Same as FunctionType
  30. try:
  31.     CodeType = type(_f.func_code)
  32. except:
  33.     pass
  34.  
  35. class _C:
  36.     def _m(self): pass
  37. ClassType = type(_C)
  38. UnboundMethodType = type(_C._m)         # Same as MethodType
  39. _x = _C()
  40. InstanceType = type(_x)
  41. MethodType = type(_x._m)
  42.  
  43. BuiltinFunctionType = type(len)
  44. BuiltinMethodType = type([].append)     # Same as BuiltinFunctionType
  45.  
  46. ModuleType = type(sys)
  47.  
  48. try:
  49.     FileType = type(sys.__stdin__)
  50. except:
  51.     pass
  52. XRangeType = type(xrange(0))
  53.  
  54. try:
  55.     raise TypeError
  56. except TypeError:
  57.     try:
  58.         tb = sys.exc_info()[2]
  59.         TracebackType = type(tb)
  60.         FrameType = type(tb.tb_frame)
  61.     except:
  62.         pass
  63.     tb = None; del tb
  64.  
  65. SliceType = type(slice(0))
  66. EllipsisType = type(Ellipsis)
  67.  
  68. del sys, _f, _C, _x                     # Not for export
  69.